<html><head></head>
<body background="../img/noa.jpg">
<?php
$cod=$_POST['fcod'];
$dia=$_POST['day'];
$mes=$_POST['month'];
$yea=$_POST['year'];
$con= mysql_connect('localhost','root','');
mysql_select_db('spa_medico');
$conUsu = mysql_query("SELECT * FROM  (select * from trata_hora where cod_tratamiento='$cod') t LEFT JOIN (select * from reserva where cod_tratamiento='$cod' AND fecha='$yea-$mes-$dia') r ON t.cod_horario=r.hora
left join tratamiento a on t.cod_tratamiento=a.cod_tratamiento left join horario h on t.cod_horario=h.cod_horario");
$num_rows = mysql_num_rows($conUsu);
$resUsu = mysql_fetch_array($conUsu);
?>
<h1 align="center"> <?php echo ($resUsu['desctrata']); ?></h1>
<table border="1" bgcolor="#95A2D5">
<tr ><td><h3 align="center">Hora</h3></td><td><h3 align="center">Paciente</h3></td></tr>
<?php 

while ($resUsu = mysql_fetch_array($conUsu)){
		echo ("<tr><td>".$resUsu['descripcion']."</td>");
		
		if($resUsu['cod_paciente'] != null)
		{
			echo ("<td>".$resUsu['cod_paciente']."</td>");
		}
		else
		{
			
			if($resUsu['cod_paciente'] != null)
			{
				echo ("<td>".$resUsu['cod_paciente']."</td>");
			}
			else
			{
				if($num_rows >= 24)
				{
					?><td bgcolor="#9BE69F"><a href="../registra/horariom.php" target="_blank">Reserva</a></td><?php
				}
				else
				{
					if($num_rows >= 18)
					{
						?><td bgcolor="#9BE69F"><a href="../registra/horarioc.php" target="_blank">Reserva</a></td><?php
					}
					else
					{
						if($num_rows >= 10)
						{
							?><td bgcolor="#9BE69F"><a href="../registra/horarioh.php" target="_blank">Reserva</a></td><?php
						}
						else
						{
							?><td bgcolor="#9BE69F"><a href="../registra/horariod.php" target="_blank">Reserva</a></td><?php
						}
					}
				}
			}
			
			
		}
}
?>

</table>

<?php 
@@mysql_free_result($conUsu);
@@mysql_close($conexion);
?>
</body>
</html>